﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Webcam.Image.Filters
{
    /// <summary>
    /// A collection of image actions
    /// </summary>
    public class ImageActionSet : ImageAction
    {
        List<ImageAction> actions = new List<ImageAction>();

        /// <summary>
        /// Add an image action
        /// DOES NOT USE THE image actions image
        /// </summary>
        /// <param name="action"></param>
        public void Add(ImageAction action)
        {
            actions.Add(action);
        }

        /// <summary>
        /// Create a set of image manipulation actions
        /// </summary>
        /// <param name="src">The image to manipluate</param>
        public ImageActionSet(RGBImage src)
            : base (src)
        {

        }

        /// <summary>
        /// Process all the images in the set
        /// </summary>
        public override void Process()
        {
            ImageAction previous = this;
            foreach (ImageAction ia in actions)
            {
                ia.src = previous.Output;
                ia.Process();
                previous = ia;
            }
            this.Output = previous.Output;
        }
    }
}
